<?

	$countries_and_states = array(
		array(
			'name'=>'France',
			'code_3'=>'FRA',
			'code_iso_numeric'=>'250',
			'code'=>'FR'
		),
		array(
			'name'=>'Germany',
			'code'=>'DE',
			'code_3'=>'DEU',
			'code_iso_numeric'=>'276',
			'states'=>array(
				'DE-BW'=>'Baden-Württemberg',
				'DE-BY'=>'Bavaria',
				'DE-BE'=>'Berlin',
				'DE-BB'=>'Brandenburg',
				'DE-HB'=>'Bremen',
				'DE-HH'=>'Hamburg',
				'DE-HE'=>'Hesse',
				'DE-MV'=>'Mecklenburg-Vorpommern',
				'DE-NI'=>'Lower Saxony',
				'DE-NW'=>'North Rhine-Westphalia',
				'DE-RP'=>'Rhineland-Palatinate',
				'DE-SL'=>'Saarland',
				'DE-SN'=>'Saxony',
				'DE-ST'=>'Saxony-Anhalt',
				'DE-SH'=>'Schleswig-Holstein',
				'DE-TH'=>'Thuringia'
			),
		),
		array(
			'name'=>'Iceland',
			'code_3'=>'ISL',
			'code_iso_numeric'=>'352',
			'code'=>'IS'
		),
		array(
			'name'=>'Ireland',
			'code_3'=>'IRL',
			'code_iso_numeric'=>'372',
			'code'=>'IE',
			'states'=>array(
				'D'=>'Dublin',
				'WW'=>'Wicklow',
				'WX'=>'Wexford',
				'CW'=>'Carlow',
				'KE'=>'Kildare',
				'MH'=>'Meath',
				'LH'=>'Louth',
				'MN'=>'Monaghan',
				'CN'=>'Cavan',
				'LD'=>'Longford',
				'WH'=>'Westmeath',
				'OY'=>'Offaly',
				'LS'=>'Laois',
				'KK'=>'Kilkenny',
				'WD'=>'Waterford',
				'C'=>'Cork',
				'KY'=>'Kerry',
				'LK'=>'Limerick',
				'TN'=>'North Tipperary',
				'TS'=>'South Tipperary',
				'CE'=>'Clare',
				'G'=>'Galway',
				'MO'=>'Mayo',
				'RN'=>'Roscommon',
				'SO'=>'Sligo',
				'LM'=>'Leitrim',
				'DL'=>'Donegal'
			)
		),
		array(
			'name'=>'Italy',
			'code_3'=>'ITA',
			'code_iso_numeric'=>'380',
			'code'=>'IT',
			'states'=>array(
				'abruzzo'=>'Abruzzo',
				'aosta_valley'=>'Aosta Valley',
				'apulia'=>'Apulia',
				'basilicata'=>'Basilicata',
				'calabria'=>'Calabria',
				'campania'=>'Campania',
				'emilia_romagna'=>'Emilia-Romagna',
				'friuli_venezia_giulia'=>'Friuli-VeneziaGiulia',
				'lazio'=>'Lazio',
				'liguria'=>'Liguria',
				'lombardy'=>'Lombardy',
				'marche'=>'Marche',
				'molise'=>'Molise',
				'piedmont'=>'Piedmont',
				'sardinia'=>'Sardinia',
				'sicily'=>'Sicily',
				'tuscany'=>'Tuscany',
				'trentino_alto_adige'=>'Trentino-Alto Adige',
				'umbria'=>'Umbria',
			)
		),
		array(
			'name'=>'Spain',
			'code_3'=>'ESP',
			'code_iso_numeric'=>'724',
			'code'=>'ES'
		),
		array(
			'name'=>'Sweden',
			'code_3'=>'SWE',
			'code_iso_numeric'=>'752',
			'code'=>'SE',
			'states'=>array(
				'stockholm'=>'Stockholm County',
				'skåne'=>'Skåne County',
				'uppsala'=>'Uppsala County',
				'västmanland'=>'Västmanland County',
				'örebro'=>'Örebro County',
				'jönköping'=>'Jönköping County',
				'östergötland'=>'Östergötland County',
				'västerbotten'=>'Västerbotten County',
				'gävleborg'=>'Gävleborg County',
				'västra_götaland'=>'Västra Götaland County',
				'södermanland'=>'Södermanland County',
				'värmland'=>'Värmland County',
				'halland'=>'Halland County',
				'kronoberg'=>'Kronoberg County'
			)
		),
		array(
			'name'=>'Austria',
			'code_3'=>'AUT',
			'code_iso_numeric'=>'040',
			'code'=>'AT',
			'states'=>array(
				'burgenland'=>'Burgenland',
				'carinthia'=>'Carinthia',
				'lower_austria'=>'Lower Austria',
				'upper_austria'=>'Upper Austria',
				'salzburg'=>'Salzburg',
				'styria'=>'Styria',
				'tyrol'=>'Tyrol',
				'vorarlberg'=>'Vorarlberg',
				'vienna'=>'Vienna'
			)
		),
		array(
			'name'=>'Belgium',
			'code_3'=>'BEL',
			'code_iso_numeric'=>'056',
			'code'=>'BE'
		),
		array(
			'name'=>'Finland',
			'code_3'=>'FIN',
			'code_iso_numeric'=>'246',
			'code'=>'FI'
		),
		array(
			'name'=>'Czech Republic',
			'code_3'=>'CZE',
			'code_iso_numeric'=>'203',
			'code'=>'CZ',
			'states'=>array(
				'PRAGUE'=>'Prague',
				'CZ-ST'=>'Central Bohemian',
				'CZ-JC'=>'South Bohemian ',
				'CZ-PL'=>'Plzeň',
				'CZ-KA'=>'Karlovy Vary',
				'CZ-US'=>'Ústí nad Labem',
				'CZ-LI'=>'Liberec',
				'CZ-KR'=>'Hradec Králové',
				'CZ-PA'=>'Pardubice',
				'CZ-OL'=>'Olomouc',
				'CZ-MO'=>'Moravian-Silesian',
				'CZ-JM'=>'South Moravian',
				'CZ-ZL'=>'Zlín',
				'CZ-VY'=>'Vysočina'
			)
		),
		array(
			'name'=>'Denmark',
			'code_3'=>'DNK',
			'code_iso_numeric'=>'208',
			'code'=>'DK',
			'states'=>array(
			)
		),
		array(
			'name'=>'Norway',
			'code_3'=>'NOR',
			'code_iso_numeric'=>'578',
			'code'=>'NO',
			'states'=>array(
				'finnmark'=>'Northern Norway/Finnmark',
				'troms'=>'Northern Norway/Troms',
				'nordland'=>'Northern Norway/Nordland',
				'nord_trøndelag'=>'Trøndelag/Nord-Trøndelag',
				'sør_trøndelag'=>'Trøndelag/Sør-Trøndelag',
				'møre_og_romsdal'=>'Western Norway/Møre og Romsdal',
				'sogn_og_fjordane'=>'Western Norway/Sogn og Fjordane',
				'hordaland'=>'Western Norway/Hordaland',
				'rogaland'=>'Western Norway/Rogaland',
				'vest_agder'=>'Southern Norway/Vest-Agder',
				'aust_agder'=>'Southern Norway/Aust-Agder',
				'telemark'=>'Eastern Norway/Telemark',
				'buskerud'=>'Eastern Norway/Buskerud',
				'hedmark'=>'Eastern Norway/Hedmark',
				'oppland'=>'Eastern Norway/Oppland',
				'akershus'=>'Eastern Norway/Akershus',
				'oslo'=>'Eastern Norway/Oslo',
				'vestfold'=>'Eastern Norway/Vestfold',
				'østfold'=>'Eastern Norway/Østfold'
			)
		),
		array(
			'name'=>'United Kingdom',
			'code_3'=>'GBR',
			'code_iso_numeric'=>'826',
			'code'=>'GB',
			'states'=>array(
				'england_avon'=>'England/Avon',
				'england_bedfordshire'=>'England/Bedfordshire',
				'england_berkshire'=>'England/Berkshire',
				'england_buckinghamshire'=>'England/Buckinghamshire',
				'england_cambridgeshire'=>'England/Cambridgeshire',
				'england_cheshire'=>'England/Cheshire',
				'england_cleveland'=>'England/Cleveland',
				'england_cornwall'=>'England/Cornwall',
				'england_cumbria'=>'England/Cumbria',
				'england_derbyshire'=>'England/Derbyshire',
				'england_devon'=>'England/Devon',
				'england_dorset'=>'England/Dorset',
				'england_durham'=>'England/Durham',
				'england_east_sussex'=>'England/East Sussex',
				'england_essex'=>'England/Essex',
				'england_gloucestershire'=>'England/Gloucestershire',
				'england_hampshire'=>'England/Hampshire',
				'england_herefordshire'=>'England/Herefordshire',
				'england_hertfordshire'=>'England/Hertfordshire',
				'england_isle_of_wight'=>'England/Isle of Wight',
				'england_kent'=>'England/Kent',
				'england_lancashire'=>'England/Lancashire',
				'england_leicestershire'=>'England/Leicestershire',
				'england_lincolnshire'=>'England/Lincolnshire',
				'england_london'=>'England/London',
				'england_merseyside'=>'England/Merseyside',
				'england_middlesex'=>'England/Middlesex',
				'england_norfolk'=>'England/Norfolk',
				'england_northamptonshire'=>'England/Northamptonshire',
				'england_northumberland'=>'England/Northumberland',
				'england_north_humberside'=>'England/North Humberside',
				'england_north_yorkshire'=>'England/North Yorkshire',
				'england_nottinghamshire'=>'England/Nottinghamshire',
				'england_oxfordshire'=>'England/Oxfordshire',
				'england_rutland'=>'England/Rutland',
				'england_shropshire'=>'England/Shropshire',
				'england_somerset'=>'England/Somerset',
				'england_south_humberside'=>'England/South Humberside',
				'england_south_yorkshire'=>'England/South Yorkshire',
				'england_staffordshire'=>'England/Staffordshire',
				'england_suffolk'=>'England/Suffolk',
				'england_surrey'=>'England/Surrey',
				'england_tyne_and_wear'=>'England/Tyne and Wear',
				'england_warwickshire'=>'England/Warwickshire',
				'england_west_midlands'=>'England/West Midlands',
				'england_west_sussex'=>'England/West Sussex',
				'england_west_yorkshire'=>'England/West Yorkshire',
				'england_wiltshire'=>'England/Wiltshire',
				'england_worcestershire'=>'England/Worcestershire',
				'wales_clwyd'=>'Wales/Clwyd',
				'wales_dyfed'=>'Wales/Dyfed',
				'wales_gwent'=>'Wales/Gwent',
				'wales_gwynedd'=>'Wales/Gwynedd',
				'wales_mid_glamorgan'=>'Wales/Mid Glamorgan',
				'wales_powys'=>'Wales/Powys',
				'wales_south_glamorgan'=>'Wales/South Glamorgan',
				'wales_west_glamorgan'=>'Wales/West Glamorgan',
				'scotland_aberdeenshire'=>'Scotland/Aberdeenshire',
				'scotland_angus'=>'Scotland/Angus',
				'scotland_argyll'=>'Scotland/Argyll',
				'scotland_ayrshire'=>'Scotland/Ayrshire',
				'scotland_banffshire'=>'Scotland/Banffshire',
				'scotland_berwickshire'=>'Scotland/Berwickshire',
				'scotland_bute'=>'Scotland/Bute',
				'scotland_caithness'=>'Scotland/Caithness',
				'scotland_clackmannanshire'=>'Scotland/Clackmannanshire',
				'scotland_dumfriesshire'=>'Scotland/Dumfriesshire',
				'scotland_dunbartonshire'=>'Scotland/Dunbartonshire',
				'scotland_east_lothian'=>'Scotland/East Lothian',
				'scotland_fife'=>'Scotland/Fife',
				'scotland_inverness-shire'=>'Scotland/Inverness-shire',
				'scotland_kincardineshire'=>'Scotland/Kincardineshire',
				'scotland_kinross-shire'=>'Scotland/Kinross-shire',
				'scotland_kirkcudbrightshire'=>'Scotland/Kirkcudbrightshire',
				'scotland_lanarkshire'=>'Scotland/Lanarkshire',
				'scotland_midlothian'=>'Scotland/Midlothian',
				'scotland_moray'=>'Scotland/Moray',
				'scotland_nairnshire'=>'Scotland/Nairnshire',
				'scotland_orkney'=>'Scotland/Orkney',
				'scotland_peeblesshire'=>'Scotland/Peeblesshire',
				'scotland_perthshire'=>'Scotland/Perthshire',
				'scotland_renfrewshire'=>'Scotland/Renfrewshire',
				'scotland_ross-shire'=>'Scotland/Ross-shire',
				'scotland_roxburghshire'=>'Scotland/Roxburghshire',
				'scotland_selkirkshire'=>'Scotland/Selkirkshire',
				'scotland_shetland'=>'Scotland/Shetland',
				'scotland_stirlingshire'=>'Scotland/Stirlingshire',
				'scotland_sutherland'=>'Scotland/Sutherland',
				'scotland_west_lothian'=>'Scotland/West Lothian',
				'scotland_wigtownshire'=>'Scotland/Wigtownshire',
				'northern_ireland_antrim'=>'Northern Ireland/Antrim',
				'northern_ireland_armagh'=>'Northern Ireland/Armagh',
				'northern_ireland_down'=>'Northern Ireland/Down',
				'northern_ireland_fermanagh'=>'Northern Ireland/Fermanagh',
				'northern_ireland_londonderry'=>'Northern Ireland/Londonderry',
				'northern_ireland_tyrone'=>'Northern Ireland/Tyrone'
			)
		),
		array(
			'name'=>'Switzerland',
			'code_3'=>'CHE',
			'code_iso_numeric'=>'756',
			'code'=>'CH'
		),
		array(
			'name'=>'New Zealand',
			'code_3'=>'NZL',
			'code_iso_numeric'=>'554',
			'code'=>'NZ',
			'states'=>array(
				'northland' =>'Northland',
				'auckland' =>'Auckland',
				'waikato' =>'Waikato',
				'bay_of_plenty' =>'Bay of Plenty',
				'east_cape' =>'East Cape',
				'hawkes_bay' =>'Hawke\'s Bay',
				'taranaki' =>'Taranaki',
				'manawatu-wanganui'=>'Manawatu-Wanganui',
				'wellington' =>'Wellington',
				'tasman' =>'Tasman',
				'nelson' =>'Nelson',
				'marlborough' =>'Marlborough',
				'west_coast' =>'West Coast',
				'canterbury' =>'Canterbury',
				'otago'=>'Otago',
				'southland' =>'Southland'
			)
		),
		array(
			'name'=>'Russian Federation',
			'code_3'=>'RUS',
			'code_iso_numeric'=>'643',
			'code'=>'RU',
			'states'=>array(
				'amur'=>'Amur',
				'arkhangelsk'=>'Arkhangelsk',
				'astrakhan'=>'Astrakhan',
				'belgorod'=>'Belgorod',
				'bryansk'=>'Bryansk',
				'chelyabinsk'=>'Chelyabinsk',
				'chita'=>'Chita',
				'irkutsk'=>'Irkutsk',
				'ivanovo'=>'Ivanovo',
				'kaliningrad'=>'Kaliningrad',
				'kaluga'=>'Kaluga',
				'kemerovo'=>'Kemerovo',
				'kirov'=>'Kirov',
				'kostroma'=>'Kostroma',
				'kurgan'=>'Kurgan',
				'kursk'=>'Kursk',
				'leningrad'=>'Leningrad',
				'lipetsk'=>'Lipetsk',
				'magadan'=>'Magadan',
				'moscow'=>'Moscow',
				'murmansk'=>'Murmansk',
				'nizhny_novgorod'=>'Nizhny Novgorod',
				'novgorod'=>'Novgorod',
				'novosibirsk'=>'Novosibirsk',
				'omsk'=>'Omsk',
				'orenburg'=>'Orenburg',
				'oryol'=>'Oryol',
				'penza'=>'Penza',
				'pskov'=>'Pskov',
				'rostov'=>'Rostov',
				'ryazan'=>'Ryazan',
				'sakhalin'=>'Sakhalin',
				'samara'=>'Samara',
				'saratov'=>'Saratov',
				'smolensk'=>'Smolensk',
				'sverdlovsk'=>'Sverdlovsk',
				'tambov'=>'Tambov',
				'tomsk'=>'Tomsk',
				'tver'=>'Tver',
				'tula'=>'Tula',
				'tyumen'=>'Tyumen',
				'ulyanovsk'=>'Ulyanovsk',
				'vladimir'=>'Vladimir',
				'volgograd'=>'Volgograd',
				'vologda'=>'Vologda',
				'voronezh'=>'Voronezh',
				'yaroslavl'=>'Yaroslavl'
			)
		),
		array(
			'name'=>'Portugal',
			'code_3'=>'PRT',
			'code_iso_numeric'=>'620',
			'code'=>'PT',
			'states'=>array(
				'lisbon'=>'Lisbon',
				'leiria'=>'Leiria',
				'santarém'=>'Santarém',
				'setúbal'=>'Setúbal',
				'beja'=>'Beja',
				'faro'=>'Faro',
				'évora'=>'Évora',
				'portalegre'=>'Portalegre',
				'castelo_branco'=>'Castelo Branco',
				'guarda'=>'Guarda',
				'coimbra'=>'Coimbra',
				'aveiro'=>'Aveiro',
				'viseu'=>'Viseu',
				'bragança'=>'Bragança',
				'vila_real'=>'Vila Real',
				'porto'=>'Porto',
				'braga'=>'Braga',
				'viana_do_castelo'=>'Viana do Castelo'
			)
		),
		array(
			'name'=>'Portugal',
			'code_3'=>'NLD',
			'code_iso_numeric'=>'528',
			'code'=>'NL',
			'states'=>array(
				'drenthe'=>'Drenthe',
				'flevoland'=>'Flevoland',
				'frisia'=>'Frisia',
				'gelderland'=>'Gelderland',
				'groningen'=>'Groningen',
				'limburg'=>'Limburg',
				'north brabant'=>'North Brabant',
				'north holland'=>'North Holland',
				'overijssel'=>'Overijssel',
				'utrecht'=>'Utrecht',
				'zealand'=>'Zealand',
				'south holland'=>'South Holland',
			)
		),
		array(
			'name'=>'Isle of Man',
			'code_3'=>'IMN',
			'code_iso_numeric'=>'833',
			'code'=>'IM'
		)
	);

	foreach ($countries_and_states as $info)
	{
		if (Db_DbHelper::scalar('select count(*) from shop_countries where code_3=:code_3', array('code_3'=>$info['code_3'])))
			continue;

		Db_DbHelper::query('insert into shop_countries(code, name, code_3, code_iso_numeric, enabled) values (:code, :name, :code_3, :code_iso_numeric, 0)', $info);

		$country_id = mysql_insert_id();
		if (isset($info['states']))
		{
			foreach ($info['states'] as $state_code=>$state_name)
			{
				Db_DbHelper::query('insert into shop_states(country_id, code, name) values (:country_id, :code, :name)', array(
					'country_id'=>$country_id,
					'code'=>$state_code,
					'name'=>$state_name
				));
			}
		}
	}

?>